//
//  WBComposeTypeButton.swift
//  新浪微博
//
//  Created by 名品导购网MPLife.com on 2017/12/11.
//  Copyright © 2017年 sweet. All rights reserved.
//

import UIKit
//UIControl 内置了touchUPInsideUp事件
class WBComposeTypeButton: UIControl {
    private lazy var imageView:UIImageView = UIImageView()
    private lazy var titleLabel:UILabel = UILabel()
    //点击按钮要展现控制器的类型
    var clsName:String?
    
    override init(frame: CGRect) {
        super.init(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        setUPui()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    //使用图像名称和标题创建按钮
    class func composeTypeButton(imageName:String,title:String)->WBComposeTypeButton {
        let btn = WBComposeTypeButton()
        btn.imageView.image = UIImage(named: imageName)
        btn.titleLabel.text = title
        return btn
    }
}
extension WBComposeTypeButton{
    func setUPui() {
        imageView.frame = CGRect(x: 15, y: 0, width: 70, height: 70)
        imageView.image = UIImage(named: "tabbar_compose_idea")
        self.addSubview(imageView)
        
        titleLabel.frame = CGRect(x: 0, y: self.frame.size.height-20, width: self.frame.size.width, height: 20)
        titleLabel.textColor = UIColor.lightGray
        titleLabel.font = UIFont.systemFont(ofSize: 15)
        titleLabel.textAlignment = .center
        self.addSubview(titleLabel)
    }
}









